var express = require('express');
var router = express.Router();
var sql = require('./../sql');
var Comment = require('./../sql/col/comments')
/**
 * @api {get} api/comment 获取评论的数据
 * @apiDescription 获取评论的数据
 * @apiGroup comment
 * @apiParam { string } productid 商品id
 * @apiSuccessExample { json } Sucess-Response:
 * {
 *  code: '200',
 *  message: '获取评论的数据',
 *  data: []
 * }
 * @apiSampleRequest /api/comment
 * @apiVersion 1.0.0
 */
router.get('/', function(req, res, next) {
  const { productid } = req.query
  sql.find(Comment, { productid }, {_id:0}).then(data => {
    res.send({
      code: '200',
      message: '获取评论的数据',
      data: data
    });
  })
});

module.exports = router;